﻿@using DTcms.Model;
@using DTcms.Common;
@{
   Layout = "~/Areas/admin/Views/Shared/_LayoutEdit.cshtml";
   ViewBag.Title = "attribute_field_edit";
   DTcms.Model.article_attribute_field m = ViewData["model"] as DTcms.Model.article_attribute_field;
   List<SelectListItem> typeList = ViewData["typeList"] as List<SelectListItem>;
   List<SelectListItem> placeList = ViewData["placeList"] as List<SelectListItem>;
}
@section HeaderContent{
   <script>
      $(function () {
         //初始化表单验证
         $("#form1").initValidform();
      });

      function getQueryParam() {
         var categoryId = $("#ddlControlType").val();
         return "control_type=" + categoryId;
      }
      //查询数据
      function search() {
         document.location = "index?" + getQueryParam();
      }
   </script>
}
<form id="form1" method="post" action="SubmitSave?action=@ViewBag.Action&id=@ViewBag.Id">
<!--导航栏-->
<div class="location">
  <a href="../attribute_field_list/index" class="back"><i class="iconfont icon-up"></i><span>返回列表页</span></a>
  <a href="../../center/index"><i class="iconfont icon-home"></i><span>首页</span></a>
  <i class="arrow iconfont icon-arrow-right"></i>
  <a href="../attribute_field_list/index"><span>扩展字段</span></a>
  <i class="arrow iconfont icon-arrow-right"></i>
  <span>编辑字段</span>
  <div class="clipboard">
     <span><label id="clipMess"></label></span>
     <a href="javascript:;" class="copy" onclick="copy();"><i class="iconfont icon-copy"></i><span>复制</span></a>
     <a href="javascript:;" class="paste disable" onclick="paste();"><i class="iconfont icon-log"></i><span>粘贴</span></a>
  </div>
</div>
<div class="line10"></div>
<!--/导航栏-->

<!--内容-->
<div id="floatHead" class="content-tab-wrap">
  <div class="content-tab">
    <div class="content-tab-ul-wrap">
      <ul>
        <li><a class="selected" href="javascript:;">字段信息</a></li>
      </ul>
    </div>
  </div>
</div>

<div class="tab-content">
  <dl>
    <dt>控件类型</dt>
    <dd>
      <div class="rule-single-select">
         @if(m.is_sys == 1){
            @Html.DropDownList("ddlControlType", new SelectList(typeList, "Value", "Text", m.control_type as string), new { disabled = "disabled" })
         }
         else{
            @Html.DropDownList("ddlControlType", new SelectList(typeList, "Value", "Text", m.control_type as string), new { onchange = "search();" })
         }
       </div>
     </dd>
  </dl>

  <dl>
    <dt>排序数字</dt>
    <dd>@Html.TextBox("txtSortId", m.sort_id, new { @class="input small", datatype="n", sucmsg=" "})<span class="Validform_checktip">*数字，越小越向前</span></dd>
  </dl>

  <dl>
    <dt>字段列名</dt>
    <dd>@Html.TextBox("txtName", m.name, new { @class="input normal", datatype=@"/^[a-zA-Z0-9\-\_]{2,50}$/", sucmsg=" ", ajaxurl="/tools/admin_ajax.ashx?action=attribute_field_validate"})<span class="Validform_checktip">*字母、下划线，不可修改</span></dd>
  </dl>

  <dl>
    <dt>字段标题</dt>
    <dd>@Html.TextBox("txtTitle", m.title, new { @class="input normal", datatype="*", sucmsg=" "})<span class="Validform_checktip">*中文标题，做为备注</span></dd>
  </dl>
  
  <dl>
    <dt>是否必填</dt>
    <dd>
      <div class="rule-single-checkbox">
         @Html.CheckBox("cbIsRequired", m.is_required == 1)
      </div>
    </dd>
  </dl>
@if(m.control_type == "single-text"){
  <dl id="dlIsPassWord" class="single-text-tr">
    <dt>是否密码框</dt>
    <dd>
      <div class="rule-single-checkbox">
         @Html.CheckBox("cbIsPassword", m.is_password == 1)
      </div>
    </dd>
  </dl>
}
@if(m.control_type == "multi-text"){
  <dl id="dlIsHtml" class="multi-text-tr">
    <dt>是否允许HTML</dt>
    <dd>
      <div class="rule-single-checkbox">
         @Html.CheckBox("cbIsHtml", m.is_html == 1)
      </div>
    </dd>
  </dl>
}
@if(m.control_type == "editor"){
  <dl id="dlEditorType" class="editor-tr">
    <dt>编辑器类型</dt>
    <dd>
      <div class="rule-multi-radio">
         <span id="rblEditorType">
            @Html.RadioButton("rblEditorType_0", "0", m.editor_type == 0)<label for="rblEditorType_0">标准型</label>
            @Html.RadioButton("rblEditorType_1", "1", m.editor_type == 1)<label for="rblEditorType_1">简洁型</label>
         </span>
      </div>
    </dd>
  </dl>
}
@if(m.control_type == "multi-radio"){
  <dl id="dlDataType" class="multi-radio-tr">
    <dt>字段类型</dt>
    <dd>
       <div class="rule-multi-radio">
          <span id="rblDataType">
             @Html.RadioButton("rblDataType_0", "nvarchar", m.data_type == "nvarchar")<label for="rblDataType_0">字符串</label>
             @Html.RadioButton("rblDataType_1", "int", m.data_type == "int")<label for="rblDataType_1">整形数字</label>
          </span>
      </div>
     </dd>
   </dl>
}
@if(m.control_type == "multi-radio" || m.control_type == "multi-checkbox"){
   <dl id="dlDataLength" class="single-text-tr multi-text-tr multi-radio-tr multi-checkbox-tr">
    <dt>字符串长度</dt>
    <dd>@Html.TextBox("txtDataLength", m.data_length, new { @class="input small", datatype="n", sucmsg=" "})<span class="Validform_checktip">*数字，默认50个字符</span></dd>
   </dl>
}
@if(m.control_type == "number"){
   <dl id="dlDataPlace" class="number-tr">
    <dt>小数点位数</dt>
    <dd>
      <div class="rule-single-select">
         @Html.DropDownList("ddlDataPlace", new SelectList( placeList, "Value", "Text", m.data_place.ToString()))
       </div>
       <span class="Validform_checktip">*无小数点为整型，否则浮点数</span>
     </dd>
   </dl>
}
@if(m.control_type == "multi-radio" || m.control_type == "multi-checkbox"){
   <dl id="dlItemOption" class="multi-radio-tr multi-checkbox-tr">
    <dt>选项列表</dt>
    <dd>
      @Html.TextArea("txtItemOption", m.item_option, new { @class="input", datatype="*", sucmsg=" "})<span class="Validform_checktip">*以换行为一行</span>
      <div>*填写说明：选项名称|值，以回车换行为一行。</div>
    </dd>
  </dl>
}
   <dl>
    <dt>默认值</dt>
    <dd>@Html.TextBox("txtDefaultValue", m.default_value, new { @class="input normal" })<span class="Validform_checktip">*控件的默认字符，可为空</span></dd>
  </dl>
@if(m.control_type == "images" || m.control_type == "video" || m.control_type == "multi-text" || m.control_type == "single-text"){
  <dl id="dlValidPattern">
    <dt>验证正则表达式</dt>
    <dd>@Html.TextArea("txtValidPattern", m.valid_pattern, new { @class="input" })<span class="Validform_checktip">*不填写则不验证</span></dd>
  </dl>
}
  <dl>
    <dt>验证提示信息</dt>
    <dd>@Html.TextArea("txtValidTipMsg", m.valid_tip_msg, new { @class="input" })</dd>
  </dl>
@if(m.control_type != "checkbox" && m.control_type != "multi-radio" && m.control_type != "multi-checkbox"){
  <dl id="dlValidErrorMsg">
    <dt>验证失败信息</dt>
    <dd>@Html.TextArea("txtValidErrorMsg", m.valid_error_msg, new { @class="input" })</dd>
  </dl>
}
</div>
<!--/内容-->

<!--工具栏-->
<div class="page-footer">
  <div class="btn-wrap">
    <input type="submit" id="btnSubmit" class="btn" value="提交保存" />
    <input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript:history.back(-1);" />
  </div>
</div>
<!--/工具栏-->

</form>
